package com.ibiaoke.marketing.dao;

import com.ibiaoke.common.base.BaseDao;
import com.ibiaoke.marketing.entity.ShareCouponRel;
import com.ibiaoke.marketing.entity.ShareCouponRelExample;
import com.ibiaoke.marketing.mapper.ShareCouponRelMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class ShareCouponRelDao extends BaseDao<ShareCouponRel, ShareCouponRelExample, Integer, ShareCouponRelMapper> {

    @Autowired
    private ShareCouponRelMapper shareCouponRelMapper;

    @Override
    public ShareCouponRelMapper getMapper() {
        return shareCouponRelMapper;
    }

    public List<ShareCouponRel> listShareCouponRel(Integer marketingId, Integer couponId) {
        ShareCouponRelExample example = new ShareCouponRelExample();
        ShareCouponRelExample.Criteria criteria = example.createCriteria();
        if(marketingId != null) {
            criteria.andMarketingIdEqualTo(marketingId);
        }
        if(couponId != null) {
            criteria.andCouponIdEqualTo(couponId);
        }
        return selectByExample(example);
    }
}
